package com.zmcc.service.impl;

import com.google.gson.Gson;
import com.zmcc.entity.common.CommonRequest;
import com.zmcc.service.INoSecretRequest;

import java.util.HashMap;
import java.util.Map;

public class NoSecretRequestCommercial implements INoSecretRequest {
    private final static String url = "https://dev.cmccopen.cn/api";

    private static NoSecretRequestCommercial noSecretRequestCommercial;

    public static synchronized NoSecretRequestCommercial getInstance() {
        if (noSecretRequestCommercial == null) {
            noSecretRequestCommercial = new NoSecretRequestCommercial();
        }
        return noSecretRequestCommercial;
    }

    @Override
    public CommonRequest getLoginRequest(String cmicAppId, String token) {
        CommonRequest request = new CommonRequest();
        request.setUrl(url+"/v1"+"/uniauth" +"/noSecretLogin");
        Map<String, String> bodyMap = new HashMap<>();
        bodyMap.put("cmicAppId", cmicAppId);
        bodyMap.put("token", token);
        request.setBody(new Gson().toJson(bodyMap));
        return request;
    }
}
